/*
	This file is part of PropExtractor.

	PropExtractor is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	PropExtractor is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with PropExtractor. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _PROPEXTRACTOR_H_
#define _PROPEXTRACTOR_H_

// PropExtractor

#include "PEIncludes.h"

#include "PEFile.h"
#include "PETools.h"
#include "PEArchive.h"
#include "PEImage.h"
#include "PEModel.h"
#include "PELoader.h"
#include "PEPath.h"

namespace pe
{

	class PE_DLL_EXPORT PropExtractor
	{

	public:

		static PropExtractor& Get();

		int InitLoader(const char* a_Name);

		int ReadFileInfo(PEFileInfo& a_Target, PEStream& a_Stream);
		int ReadFileInfo(PEFileInfo& a_Target, const wchar_t* a_Path);

		PEObject* LoadFile(const wchar_t* a_Path);
		PEObject* LoadFile(PEStream& a_Stream);

		int LoadRawArchive(PEArchiveRaw& a_Target, const wchar_t* a_Path);
		int LoadRawImage(PEImageRaw& a_Target, const wchar_t* a_Path);
		int LoadRawImage(PEImageRaw& a_Target, PEStream& a_Stream);

	private:

		PropExtractor();
		~PropExtractor();

		static PropExtractor* s_Instance;

		struct LoaderNode
		{
			LoaderNode()
			{
				handle = NULL;
				next = NULL;
			}
			~LoaderNode()
			{
				if (next) { delete next; }
				delete handle;
			}

			PELoader* handle;
			LoaderNode* next;
		};

		LoaderNode* m_LoaderFirst;
		LoaderNode* m_LoaderCurrent;

	};

}; // namespace pe

#endif